<%--
  Created by IntelliJ IDEA.
  User: sakura
  Date: 2019/6/4
  Time: 8:57
  To change this template use File | Settings | File Templates.
--%>
<%@page import="com.topup.pojo.Student"%>
<%@page import="com.topup.pojo.User"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
 <%
 
 	Student stu =(Student) request.getSession().getAttribute("stu");
 
 %>
<!doctype html>
<html>
<head>
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" /><!-- bootstrap-CSS -->
    <link href="css/font-awesome.css" rel="stylesheet" type="text/css" media="all" /><!-- Fontawesome-CSS -->
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
    <script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <meta charset="utf-8">
    <title>Header</title>
</head>

<body>
<header>
    <div class="container">
        <!--logo-->
        <div class="logo">
            <h1><a href="#">校园充值系统</a></h1>
        </div>
        <!--//logo-->
        <div class="w3layouts-login">
        <c:if test="${stu!=null }">
        <a   data-target="#myModal" href="IdexCenten.jsp">${ stu.name }</a>
        	<a href="StudentCenten.jsp"><img style="width: 20px;height: 20px;" alt="主页" src="<%=basePath%>images/user1.png"></a>
        </c:if>
        
       <c:if test="${stu==null }">
        <a data-toggle="modal" data-target="#myModal" href="#"><em class="glyphicon glyphicon-user"> </em>登录/注册</a></div>
          </c:if>
        <div class="clearfix"></div>
        <!--Login modal-->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
             aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;</button>
                        <h4 class="modal-title" id="myModalLabel">
                            校园充值系统</h4>
                    </div>
                    
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-8 extra-w3layouts" style="border-right: 1px dotted #C2C2C2;padding-right: 30px;">
                                <!-- Nav tabs -->
                                <ul class="nav nav-tabs">
                                    <li class="active"><a href="#Login" data-toggle="tab">登录</a></li>
                                    <li><a href="#Registration" data-toggle="tab">注册</a></li>
                                </ul>
                                <!-- Tab panes -->
                                
                                <div class="tab-content">
                                    <div class="tab-pane active" id="Login">
                                       
                                       		     <div class="form-group">
                                                <label for="email" class="col-sm-2 control-label">
                                                    账号</label>
                                                <div class="col-sm-10">
                                                    <input type="text" class="form-control" id="email1" placeholder="请输入账号" required="required" />
                                                </div>
                                            </div>
                                            <br/> <br/>
                                            <div class="form-group">
                                                <label for="exampleInputPassword1" class="col-sm-2 control-label">
                                                    密码</label>
                                                <div class="col-sm-10">
                                                    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="请输入密码" required="required" />
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-sm-2">
                                                </div>
                                                <div class="col-sm-10">
                                                <br/>
                                                &nbsp;&nbsp;&nbsp;<button onclick="logon()"  class="submit btn btn-primary btn-sm">
                                                     		   登录</button>
                                                      <button onclick="loginadmin()"  class="submit btn btn-primary btn-sm">
                                                     		  我是管理员</button>
                                                        </div>
                                            </div>
                                       
                                    </div>
                                    <div class="tab-pane" id="Registration">
                                    	<div class="tab-pane" id="Registration">
												<form class="form-horizontal" >
													<div class="form-group">
														<label for="email" class="col-sm-2 control-label">
															账号</label>
														<div class="col-sm-10">
															<input type="text" class="form-control" id="username"
																required="required" />
														</div>
													</div>
													<div class="form-group">
														<label for="mobile" class="col-sm-2 control-label">
															密码</label>
														<div class="col-sm-10">
															<input type="password" class="form-control" id="userpwd"
																required="required" />
														</div>
													</div>
													<div class="form-group">
														 
													</div>
													<div class="form-group">
														<label for="mobile" class="col-sm-2 control-label">
															性别</label>
														<div class="col-sm-10">
																<input type="radio" value="男" name="sex"
																required="required" />男
																 <input type="radio" value="女"
																name="sex" required="required" />女
														</div>
													</div>
													<div class="form-group">
														<label for="mobile" class="col-sm-2 control-label">
															班级</label>
														<div class="col-sm-10">
															<input type="text" class="form-control" id="classs"
																required="required" />
														</div>
													</div>
													<div class="form-group">
														<label for="mobile" class="col-sm-2 control-label">
															电话号码</label>
														<div class="col-sm-10">
															<input type="text" class="form-control" id="phone"
																required="required" />
														</div>
													</div>
													<div class="form-group">
														<label for="mobile" class="col-sm-2 control-label">
															邮箱</label>
														<div class="col-sm-10">
															<input type="text" class="form-control" id="email"
																required="required" />
														</div>
													</div>


													<div class="row">
														<div class="col-sm-2"></div>
														<div class="col-sm-10">
															<button type="submit"
																class="submit btn btn-primary btn-sm" onclick="add()">注册</button>
															<button type="reset"
																class="submit btn btn-default btn-sm">重置</button>
														</div>
													</div>
												</form>
											</div>
                                </div>
                                
                                
                            </div>
                        </div>
                        
                    </div>
                    
                    
                </div>
            </div>
        </div>
        <!--//Login modal-->
    </div>
</header>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;</button>
                <h4 class="modal-title" id="myModalLabel">
                    校园充值系统</h4>
            </div>
             
            </div>
        </div>
    </div>
</div>

<script src="js/bootstrap.js"></script>
<!-- //for bootstrap working -->
<!-- here stars scrolling icon -->

<script type="text/javascript">
		function logon() {

			var name1 = $('#email1').val();
			var pwd1 = $("#exampleInputPassword1").val();
			 
			$.ajax({
				type : "POST",
				url : "<%=basePath%>stu/loginstu",
				dataType : 'json',
				data : {
					"username" : name1,
					"userpwd" : pwd1

				},
				success : function(result) {
					 if (result.status == 0) {
						alert("欢迎登陆")
						 window.location.href="AboutCenten.jsp";
							
					}else if(result.status==1){
						alert("账户或密码不对")
					}	
				},
				error : function(result) {
					 
					alert("异常！");
				}

			});
		}
		function loginadmin() {
			var name1 = $('#email1').val();
			var pwd1 = $("#exampleInputPassword1").val(); 
			$.ajax({
				type : "POST",
				url : "<%=basePath%>admin/Adminlogin",
				dataType : 'json',
				data : {
					"username" : name1,
					"userpwd" : pwd1
				},
				success : function(result) {
					if (result.status == 0) {
						alert("欢迎登陆")
						  window.location.href="car.jsp";
	    				
						
					}else{
						alert("账号或密码不对")
					}
					 	
					 	
				},
				error : function(result) {
					 
					alert("异常！");
				}
			});
		}

		function add() {

			var name1 = $('#username').val();
			var pwd1 = $("#userpwd").val();
			var classs = $('#classs').val();
			var phone = $('#phone').val();
			var email = $("#email").val();
			
		  

			$.ajax({
				type : "POST",
				url : "<%=basePath%>user/add",
				dataType :'json',
				data : {
					"name" : name1,
					"pwd" : pwd1,
					"classs" : classs,
					"phone" : phone,
					"email":email,
					 
				},
				success : function(result) {
					alert(result.status)
					if(result.status==1){
						 alert("注册成功!")
						 window.location.href="AboutCenten.jsp";
					}else {
						 alert("注册失败!")
					}
					
				},
				error : function(result) {
					alert("异常！");
				}

			});
		}
	</script>


<script type="text/javascript">
    $(document).ready(function() {
        /*
            var defaults = {
            containerID: 'toTop', // fading element id
            containerHoverID: 'toTopHover', // fading element hover id
            scrollSpeed: 1200,
            easingType: 'linear'
            };
        */

        $().UItoTop({ easingType: 'easeOutQuart' });

    });
</script>
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(".scroll").click(function(event){
            event.preventDefault();
            $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
        });
    });
</script>

</body>

</html>
